<?php
	if ( strcasecmp( @ $_SERVER['REQUEST_METHOD'], 'POST' ) == 0 )
    {
		$err=array();
		if($_POST['currentpass'] != $_SESSION['password'])
		{
			$er=array('currentpass'=>'Your current password is invalid !!');
			$err=array_merge($err,$er);
			alert("Your current password is invalid !!");
		}
		if($_POST['newpass'] != $_POST['cnewpass'] || $_POST['newpass']=="")
		{
			$er=array('cnewpass'=>'Password was not match!!');
			$err=array_merge($err,$er);
			alert("Password was not match !!");
		}
		if(count($err)==0)
		{
			$obj=new User();
			$obj->loadByKey($_SESSION['username']);
			$obj->Pass=$_POST['newpass'];
			if($obj->update($conn))
			{
				alert("Password was changed successfully.");
				linkto("?");
			}
		}
	}
?>
<div class="ContentTitle">
    <div class="left" style="padding-top:8px"><?php echo $objModule->ModuleName?></div>
    <div class="CMSButton right">
        <a onclick="f.submit()">Save</a>
        <a href="?">Cancel</a>
        
    </div>    
    <div class="clear"></div>
</div>
<ul id="ContentTabs" class="shadetabs">
    <!--
    <li><a class="selected" onclick="ShowHideDiv('Tab',1,2)">General Information</a></li>
    <li><a onclick="ShowHideDiv('Tab',1,2)">Account Information</a></li>
    -->
</ul>       

<div id="Tab1" class="TabContainer" style="display:block">
<!-------------CONTENT OF EACH MODULE ---------------------------->
<form name="f" action="" method="post">
<table>
	<tr>
		<td>
			User Name:
		</td>
		<td>
			<?php echo $_SESSION['username']?>
		</td>
	</tr>
	<tr>
		<td>
			Current password:
		</td>
		<td>
			<input type="password" name="currentpass" />
		</td>
	</tr>
	<tr>
		<td>
			New password:
		</td>
		<td>
			<input type="password" name="newpass" />
		</td>
	</tr>
	<tr>
		<td>
			Confirm new password:
		</td>
		<td>
			<input type="password" name="cnewpass" />
		</td>
	</tr>
</table>
</form>
<!-------------END CONTENT OF EACH MODULE ---------------------------->
</div>